package thired.algorithm;

import java.util.ArrayList;
import java.util.Arrays;

import static java.util.Arrays.sort;

public class searchThreadWidth {
    public static ArrayList<ArrayList<Integer>> searchThreadWidth(int[] threadWidths,int[] tireCounts){
        if(threadWidths == null || tireCounts == null || threadWidths.length == 0 || tireCounts.length == 0){
            return null;
        }
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < tireCounts.length; i++) {
            max = tireCounts[i] > max ? i : max;
        }
        max = threadWidths[max];
        Integer[] threadWidth = Arrays.stream(threadWidths).boxed().toArray(Integer[]::new);
      Arrays.sort(threadWidth,(a,b)->{return b-a;});
        ArrayList<ArrayList<Integer>> result = new ArrayList<>();
        ArrayList list = new ArrayList<>(Arrays.asList(threadWidth));
        result.add(list);
        ArrayList<Integer> list2 = new ArrayList<>();
        list2.add(threadWidth[0]);
        list2.add(max);
        result.add(list2);
        return result;
    }

    public static void main(String[] args) {
        int[] threadWidths = {155,175,165,195,215};
        int[] tireCounts = {5,7,8,13,2};
        ArrayList<ArrayList<Integer>> result = searchThreadWidth(threadWidths, tireCounts);
        System.out.println(result);
    }
}
